package com.example.wm.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.wm.common.Result;
import com.example.wm.common.ResultData;
import com.example.wm.entity.FundConcentration;
import com.example.wm.mapper.FundConcentrationMapper;
import com.example.wm.utils.TsyUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Slf4j
@RestController
@RequestMapping("/FundConcentration")
public class FundConcentrationContoller {
    @Resource
    private FundConcentrationMapper fundConcentrationMapper;
    @Resource
    private TsyUtils tsyUtils;
    @PostMapping("/insert")
    public Result insert(@RequestBody FundConcentration fundConcentration){
        fundConcentration.setCreatetime(tsyUtils.getnowtime());
      int b=  fundConcentrationMapper.insert(fundConcentration);
        return ResultData.success(b);
    }
    @PostMapping("/findgsname")
    public Result findgsname(){
        LambdaQueryWrapper<FundConcentration> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        List<FundConcentration> list=fundConcentrationMapper.selectList(lambdaQueryWrapper);
        //set数组去重
        Set<String> set=new HashSet<>();
         for (FundConcentration f:list){
             f.getComponey();
             set.add(f.getComponey());
         }
        return ResultData.success(set);
    }
}
